﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LGCourt.Logic.NBL.DBEntities;
using LGCourt.Logic.BLL;

namespace lgweb.Judge
{
    public partial class liandetail : System.Web.UI.Page
    {      
        private string _ID = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {           
            if (!this.IsPostBack)
            {
                getInfo();
            }
        }

        private void getInfo()
        {
            this._ID = string.IsNullOrEmpty(Request.QueryString["id"]) ? "0" : Request.QueryString["id"];

            pPreCaseInfo param = new pPreCaseInfo();
            param.PreCaseInfoID = int.Parse(this._ID);
            PreCase bll = new PreCase();
            PreCassCollection result = (PreCassCollection)bll.GetPreCaseInfo(param);

            if (result != null && result.PreCaseInfo!=null)
            {
                //this.hdnPreCaseInfoID.Value = result.PreCaseInfo.PreCaseInfoID.ToString();
                this.tdPreCaseSerial.InnerHtml = result.PreCaseInfo.PreCaseSerial;
                this.tdEmail.InnerHtml = result.PreCaseInfo.Email;
                this.tdPhone.InnerHtml = result.PreCaseInfo.Phone;
                switch (result.PreCaseInfo.PreCaseType)
                {
                    case 1:
                        this.tdPreCaseType.InnerHtml = "民事案件";
                        break;
                    case 2:
                        this.tdPreCaseType.InnerHtml = "商事案件";
                        break;
                    default:
                        this.tdPreCaseType.InnerHtml = "执行案件";
                        break;
                }
                this.tdHandleStatus.InnerHtml = result.PreCaseInfo.HandleStatus == 0 ? "未处理" : "已处理";
                this.tdAddDateTime.InnerHtml = result.PreCaseInfo.AddDateTime.ToString();
                this.tdAudited.InnerHtml = result.PreCaseInfo.Audited == 0 ? "未审核" : "已审核";
                this.tdCauseOfAction.InnerHtml = result.PreCaseInfo.CauseOfAction;
                this.tdReplyContent.InnerHtml = result.PreCaseInfo.ReplyContent;

                //原告
                this.Repeater1.DataSource = result.PrePartiesList.Where(a => a.PartiesClass == 1 && a.PartiesType == 0).ToList();
                this.Repeater1.DataBind();
                this.Repeater2.DataSource = result.PrePartiesList.Where(a => a.PartiesClass == 2 && a.PartiesType == 0).ToList();
                this.Repeater2.DataBind();
                this.Repeater3.DataSource = result.PrePartiesList.Where(a => a.PartiesClass == 3 && a.PartiesType == 0).ToList();
                this.Repeater3.DataBind();

                //被告
                this.Repeater4.DataSource = result.PrePartiesList.Where(a => a.PartiesClass == 1 && a.PartiesType == 1).ToList();
                this.Repeater4.DataBind();
                this.Repeater5.DataSource = result.PrePartiesList.Where(a => a.PartiesClass == 2 && a.PartiesType == 1).ToList();
                this.Repeater5.DataBind();
                this.Repeater6.DataSource = result.PrePartiesList.Where(a => a.PartiesClass == 3 && a.PartiesType == 1).ToList();
                this.Repeater6.DataBind();

                //证据文件
                //if (result.PreCaseFile != null && result.PreCaseFile.Count() > 0)
                //{
                //    this.rptFile.Visible = true;
                //    this.rptFile.DataSource = result.PreCaseFile;
                //    this.rptFile.DataBind();
                //}

            }
        }
        
    }
}